At the highest level in the Actor class hierarcy is the Actor class. In this class, functions are defined in several ways. A function can be considered so characteristic of given object that the object should always be created with the behavior the function defines. This is one purpose of the event keyword. It allows programmers to establish a function as an event a primary characteristic of the object it is associated with. For this reason, in the definition of the Actor class, you find the PostBeginPlay() function identified as an event. Both functions here appear without reference to any previous versions. The defitions you see here constitute the primary definitions of the functions. When you see a function declared in this way, the function constitutes an abstract function. An abstruct function is a function that has not content. Notice, for example, that the two functions lack blocks. There is no code associated with them. They are declared so that you know their return types and the arguments they take, but what they do remains to be seen.
//As defined in the Actor class
event PostBeginPlay();
event Touch( Actor Other );
The Trigger class is derived from the Actor class. When you derive one class from another, as has been mentioned before, if the functions in the base class are defined with public access, then you can calll them them in the classes you derive from them. In the Actor class, you see no access modifiers in the defintion of the PostmBeginPlay()and SetInitialState() functions, so they are in this respect implicitly defined as public functions. As publich functions, they can be readily accessed in the Trigger class.
In this case, the situation differs from those you are likely to encounter when you define your functions, for the functions in the parent class are abstract. The Trigger class provides a context in which to define them. Here are the defitions as they appear in the Trigger class:
//As defined in the Trigger class
function PostBeginPlay()
{
if ( !bInitiallyActive )
FindTriggerActor();
if ( TriggerType == TT_Shoot )
{
bHidden = false;
bProjTarget = true;
SetDrawType(DT_None);
}
bSavedInitialActive = bInitiallyActive;
bSavedInitialCollision = bCollideActors;
Super.PostBeginPlay();
}
//As defined in the Trigger class
function Touch( actor Other )
{
local int i;
if( IsRelevant( Other ) )
{
Other = FindInstigator( Other );
if ( ReTriggerDelay > 0 )
{
if ( Level.TimeSeconds - TriggerTime < ReTriggerDelay )
return;
TriggerTime = Level.TimeSeconds;
}
// Broadcast the Trigger message to all matching actors.
TriggerEvent(Event, self, Other.Instigator);
if ( (Pawn(Other) != None) && (Pawn(Other).Controller != None) )
In the Trigger class, you see two things. First, the signature lines of the functions are restated with the keyword function but in other resepcts, they remain the same as those that appear in the base class. Using the function keyword rather than the event keyword indicates that in this case they are to be defined. In other words, code is to be added to them that gives them functionality. To add the code, opening and closing curely braces are add, an statments then appear in the function block the braces create.
A second feature is that in the redefintion of the PostBegin() play method, you see a call to the Super.PostBeginPlay() function. . When you define a function, you provide it with a content.